# -*- coding: utf-8 -*-
"""
copy files from src_dir to dst_dir recursively
"""

import os
import shutil
import sys
import argparse


def copy_files(src_dir, dst_dir):
    """
    copy files from src_dir to dst_dir recursively
    :param src_dir: source directory
    :param dst_dir: destination directory
    :return: None
    """
    file_num = 0
    for root, _, files in os.walk(src_dir):
        for file_name in files:
            src_file_full_path = os.path.join(root, file_name)
            dst_file_full_path = os.path.join(dst_dir, file_name)
            shutil.copyfile(src_file_full_path, dst_file_full_path)
            file_num = file_num + 1
    print("Copied: {} files".format(file_num))


if __name__ == '__main__':
    try:
        SRC_DIR = sys.argv[1]
        DST_DIR = sys.argv[2]
    except:
        PARSER = argparse.ArgumentParser(description="arguments")
        PARSER.add_argument("--src_dir", type=str,
                            default="/home/chujie/PycharmProjects/data_tool/data/voc2012",
                            help="VOC dataset root directory")
        PARSER.add_argument("--dst_dir", type=str, default=os.getenv("HOME"),
                            help="destination directory")
        ARGS = PARSER.parse_args()
        SRC_DIR = ARGS.src_dir
        DST_DIR = ARGS.dst_dir

    copy_files(SRC_DIR, DST_DIR)
